<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>二维码管理</title>
<meta name="decorator" content="default" />
	<script type="text/javascript">
		$(document).ready(function() {
			var proProductTwoDimlCode=$("#proProductTwoDimlCode").val();
			var fastdfs_file_url=$("#fastdfs_file_url").val();
			if(proProductTwoDimlCode!=""){
				var contextPath=$("#contextPath").val();
				$("#twoDimlCodePic").attr("src", fastdfs_file_url+proProductTwoDimlCode+'?t='+Math.random());
			}else{
				$("#twoDimlCodePic").hide();
				top.$.jBox.tip('未生成二维码！','warning');
			}
		});
		function createTwoDimlCode(productId){
			loading('正在生成二维码，请稍等...');
			$.getJSON("${ctx}/product/product/proProduct/createTwoDimlCode",{productId:productId},function(data){
				if(data.success){
					top.$.jBox.tip('生成二维码成功！','info');
					$("#twoDimlCodePic").show();
					$("#twoDimlCodePic").attr("src", data.fastdfs_file_url+data.proProduct.twoDimlCode+'?t='+Math.random());
				}else{
					top.$.jBox.tip('生成二维码失败！','warning');
				}
			});
		}
	</script>

</head>

<body>
    <div style="margin:10px;">
		<input id="btnLicensePic" class="btn btn-primary" type="button" onclick="createTwoDimlCode('${proProduct.id}')" value="${not empty proProduct.twoDimlCode?'重新':''}生成二维码"/>
	</div>
	<div style="margin:10px;">
		<input type="hidden" id="fastdfs_file_url" value="${fastdfs_file_url}" />
		<input type="hidden" id="productId" value="${proProduct.id}" />
		<input type="hidden" id="proProductTwoDimlCode" value="${proProduct.twoDimlCode}" />
		<img id="twoDimlCodePic" src=""/>
	</div>
</body>

</html>
